#include <QtGlobal>

#if QT_VERSION >= 0x050000
#include <QtWidgets/QApplication>
#else
#include <QtGui/QApplication>
#endif

#include "mainwindow.h"
#include <QTextCodec>
#include <QApplication>
#include <QWidget>
#include <QVBoxLayout>
#include <QLabel>
#include <QScrollArea>
#include <QtSerialPort/QSerialPortInfo>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
	QString lang = "zh";//默认显示中文
	if (argc == 2)
		lang = QString::fromLatin1(argv[1]);

#if QT_VERSION < 0x050000
	// 以下部分解决中文乱码
	QTextCodec::setCodecForTr(QTextCodec::codecForName("GB2312"));
	QTextCodec::setCodecForLocale(QTextCodec::codecForName("GB2312"));
	QTextCodec::setCodecForCStrings(QTextCodec::codecForName("GB2312"));
	// 以上部分解决中文乱码    
#endif

	QTranslator translator(0);
	QString filename;
	filename = "language\\delucom_" + lang + ".qm";
	bool loadok = translator.load(filename, "");
	if (!loadok)
		qDebug()<<"load translator file \""<<filename<<"\" failed!";

	a.installTranslator(&translator);

	MainWindow w;
    w.show();
    return a.exec();
}